package com.aloha.springframework.context.event;

import com.aloha.springframework.beans.factory.BeanFactory;
import com.aloha.springframework.context.ApplicationEvent;

/**
 * @author DaiZhiHeng
 * @description 事件广播器的简单是实现
 * @date 2023/7/4 8:04
 */
public class SimpleApplicationEventMulticaster extends AbstractApplicationEventMulticaster {

    public SimpleApplicationEventMulticaster(BeanFactory beanFactory) {
        setBeanFactory(beanFactory);
    }

    @Override
    @SuppressWarnings("unchecked")
    public void multicastEvent(ApplicationEvent event) {
        getApplicationListeners(event).forEach(listener -> listener.onApplicationEvent(event));
    }
}
